'==================================================================================================
'	Author		David Segura
'	URL			http://winpeguy.com/
'	Source		http://winpe.codeplex.com/
'	Version		20130910
'==================================================================================================
'	Purpose:
'	Core Menu Functions
'==================================================================================================
'	File Locations in Windows:
'	%DeployRoot%\Boot\+WinPE\Menu\Scripts\Menu.vbs
'==================================================================================================
'	File Location in WinPE:
'	X:\Menu\Scripts\Menu.vbs
'==================================================================================================
'	Configuration:
'	None.  Editing this file is not recommended
'==================================================================================================
'	Change Log:
'	20130910	Codeplex Beta
'==================================================================================================
	strComputer = "."
	Set objWMIService = GetObject("winmgmts:\\.\root\CIMV2")
	Set objShell = CreateObject("Wscript.Shell")
	Set objFSO = CreateObject("Scripting.FileSystemObject")
	Set WshShell = CreateObject("WScript.Shell")

	Set objRegistry = GetObject("winmgmts:\\" & _ 
			strComputer & "\root\default:StdRegProv")
		
		Const HKEY_CLASSES_ROOT			= &H80000000
		Const HKEY_CURRENT_USER			= &H80000001
		Const HKEY_LOCAL_MACHINE		= &H80000002
		Const HKEY_USERS				= &H80000003
		Const HKEY_CURRENT_CONFIG		= &H80000005
'==================================================================================================
	strKeyPath = "SYSTEM\@WinPE"
	envComputerName = WshShell.ExpandEnvironmentStrings("%ComputerName%")
	strValueName = "WinPE-ComputerName"
	objRegistry.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,envComputerName
	
	envSystemDrive = WshShell.ExpandEnvironmentStrings("%SystemDrive%")
	strValueName = "WinPE-SystemDrive"
	objRegistry.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,envSystemDrive
	
	envSystemRoot = WshShell.ExpandEnvironmentStrings("%SystemRoot%")
	strValueName = "WinPE-SystemRoot"
	objRegistry.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,envSystemRoot

	envTemp = WshShell.ExpandEnvironmentStrings("%Temp%")
	strValueName = "WinPE-Temp"
	objRegistry.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,envTemp

	envSystem32 = envSystemRoot & "\System32"
	strValueName = "WinPE-System32"
	objRegistry.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,envSystem32
	
	envUserName = WshShell.ExpandEnvironmentStrings("%UserName%")
	strValueName = "WinPE-UserName"
	objRegistry.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,envUserName
	
	envComSpec = WshShell.ExpandEnvironmentStrings("%ComSpec%")
	strValueName = "WinPE-ComSpec"
	objRegistry.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,envComSpec
	
	envProcessorArchitecture = WshShell.ExpandEnvironmentStrings("%PROCESSOR_ARCHITECTURE%")	'Will return x86 or AMD64
	strValueName = "WinPE-ProcessorArchitecture"
	objRegistry.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,envProcessorArchitecture
	
	If lcase(envProcessorArchitecture) = "amd64" Then
		envBootArch = "x64"
		envBootBit = "64"
	Else
		envBootArch = "x86"
		envBootBit = "32"
	End If
	
	strCurrentDirectory = objShell.CurrentDirectory
	strValueName = "WinPE-CurrentDirectory"
	objRegistry.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strCurrentDirectory
	
	strMenuDir = "X:\Menu"
	strValueName = "WinPE-MenuDir"
	objRegistry.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strMenuDir
	
	strScriptsDir = strMenuDir & "\Scripts"
	strValueName = "WinPE-ScriptsDir"
	objRegistry.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strScriptsDir
'==================================================================================================
	Dim strPEBootType, strPEBootDrive
	strKeyPath = "SYSTEM\@WinPE"
	objRegistry.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,"BootMediaType",strPEBootType
	'This will return a value of PXE CD-ROM or DRIVE
	objRegistry.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,"BootMediaDrive",strPEBootDrive
	'This will return a drive letter D:\ or NONE
'==================================================================================================
	Set colComputer = objWMIService.ExecQuery("Select * from Win32_ComputerSystem") 

	GB = 1024 * 1024 * 1024
		
	For Each objComputer in colComputer 
		strTotalRAM =  Round(objComputer.TotalPhysicalMemory / GB,2)
	Next 
'==================================================================================================
	Sub Window_OnLoad
		Dim Width, Height
		Width = screen.AvailWidth
		If Width <= 1024 Then
			Height = 510
		Else
			Height = 600
		End If
		self.ResizeTo Width , Height
		self.MoveTo 0 , 140
		subBGInfo
	End Sub
'==================================================================================================	
	Sub subComingSoon
			MsgBox "Coming Soon" & vbCrLf & "" & vbCrLf & _
			"This application is not currently enabled in this release",16,MsgBoxTitleShort & "Coming Soon"
	End Sub
'==================================================================================================
	Function RegKeyExists(Key)
		Dim oShell, entry
		On Error Resume Next

		Set oShell = CreateObject("WScript.Shell")
			entry = oShell.RegRead(Key)
		If Err.Number <> 0 Then
			Err.Clear
			RegKeyExists = False
		Else
			Err.Clear
			RegKeyExists = True
		End If
	End Function
'==================================================================================================